package com.example.blog.common;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 统一异常处理
 */
@RestControllerAdvice
public class ExceptionAdvice {
    // 处理所有异常
    @ExceptionHandler(Exception.class)
    public ResultAjax doException(Exception e) {
        // 返回失败结果
        return ResultAjax.fail(-1, e.getMessage());
    }
}